used map instead of for loop