Not sure, but I think this is incorrect. The original only returns if the class is present, and keeps iterating through the collection otherwise (to eventually return false if none of the elements' class names contained it).

This code however is always returning after the first element.