TODO: fix the bug that the reducer's loop will not end