Refactor error check

Error checking code should not be in the instance search code.