changed global variables to module instance variables