refactor ast functionality