Refactoring find and rfind.