Fixed undefined variables and Syntax Errors