handling back button on main page