Refactored word search