Use Functional/map instead of foreach