change global variable to instance variable