fixed bugs in median filter