Move dd_total to global scope