Update search function to use exceptions.