Fixing back button behaviour