fixed issue where multiple, identical nodes in an ast caused env collisions
use before instead of let for updating counters