adds improved and tested version of median-filter