added implementation of checkVariableDeclared and checkFunctionDeclared