add balance function to progfun-recfun project