Added median and calc function