Fix bug with median filter