handles errors in search