swapped out global variables for instance variables