Refined back button functionality