forgot to update prevElevations[i] on each iter