correcting an undefined variable issue