added logic to back button