fix syntax errors; reorganize code to use node as identifier