You are performing a search here anyway, you need to check the input before calling the search.