minor changes to median code
fix small error in median