updated total and sum methods for JSAPI