fix bug in reduction routine