fixed median bug