Actually finished the reducer (fixing the bug of "Why is there no output?").