caching added(this caching works only on my program, because we have just only about 10 states)