cleaned up how some back button code works