refactored, uses .forEach method