fixed a corner bug in median, as well as percentiles