Updated next button functionality and added previous button.