Changed iterator to loop over 'pins'