Refactor calculation of route grade