Moved median method to helper.