fix bugs in reducer