fixed error with used_oldstate
added lookup table