implemented 1D median filter