modify to use map instead of each with an array