added back button and written page switching logic