changed global vars to instance vars