use map instead of each