implement session history and back button logic