changed global variables to instance variables

added initialize method and replaced global variables with instance
variables