use .hasOwnProperty method to verify validity of the search query
minor change