Refactor: remove collectVariables method; not it's using a visitor