Wait for forEach to complete