Working code w4.1 median