iterating over components and terminals in the components