minor bug in cumulative func