added error handling for invalid search term