removing global variables... work in progress