Fix a bug in reduce()