properly scope attachment iterator