This could be more efficient (we are comparing with 'class' in every iteration), but its not a big deal