Added nextPath() to the controller and implemented pagination