working back button handling