Fix exception in reduce