turned for loop into map function