Switched to using forEach to loop arrays