Refactor calculate maxes