function to calculate median is added which fixes #3