Fixed undeclared variable isssues