Median bugfix