Implementation/fix of reduceInner