fixed bug with undefined variables.