Refactored the find function.