redid fix to CapGains calculation