Could just use the string indexOf function for this test (and looking for @ and i) as a simplification.