Fixing issue when pressing back key and navigating back