Fix bug in reducer with wrong indexing.