ReduceFraction function