fixed problems with stateful vars