Implement logic for Previous/Next links