median working for both off and even numbers