some major refactoring so I make an AST first and then render it.