included a variable nStates to determine the dimension of te problem
the buffer logic seems to work, still got to test the buffer-reset triggers