pulled out prev and next positions into a method to clean up the controller