changed the api of reduceOrElse to be reduceOption instead