Replacing $.each with forEach