use a string.find-based approach for simplicity and speed