Adding median calculation