added median solution