fixed some bugs in the reducer