make use of .each instead of for loop