added back logic for back button press