updated contains block with for each loop