adding state to each node

to try and reduce number of times each node is evaluated