added median to code.