use foreach instead of map