Use map instead of foreach