fixed error with undefined variables.