added solution to find the median