Replaced loops with "map"