Handled the null exception in search.