added checking of undefined variables