Refactored prevnext