Add median and average calculation