Replaced array.forEach to an array.filter