handling back button in main page