Fix moving to the last page when clicking the button on the navigation bar