removed foreach loops