clean up median calc