change "for" loop to "forEach()" function