Use a map instead of for loop.