javascript foreach loop async