refactored shiftNext