refactor to clean up complex find method