fix recursion bug
optimize forEach to read in loop when sync