find the median added - needs little fixing