Check the type of the class variable to determine when to stop iterating as well