Implementing a reducer and integrating it with the store