I think you can save some iterations by immediately returning. Are you sure that it only hits once?