Added back button functionality, better handling of search cases