refactoring, reformed syntax, improve error reporting