cleaned up page navigation logic