Undeclared variables fixed