added checks for undeclared variables in assignments and some corrections