reconfigured for use of global variables