Made median instead of average