Delivering good quality of power is the main agenda for distribution system to the loads. But maintain power quality is not so easy due to the load variations in the system. Sag and swell are the main factors that affect power quality. In this paper, multiple sag conditions and swell conditions were tested by producing the condition in different phases of the system. A simple algorithm called RMS algorithm was developed and tested for the said conditions. Sag and swell were generated on single phase and multiple phases for testing the algorithm. The algorithm and the results were obtained using Matlab. .DVR is installed between supply and load which will inject voltage and active power to the distribution system during balanced/unbalanced voltage sag and swell disturbances. The performance of DVR based of voltage sag, swell is going to be tested and Simulation results are going to be carried out by MATLAB with its Simu-link to analyze the proposed method.