update composite pattern

Eliminate global variables