fixed median calculation