dealing with danger of global variables