reconstruction states.py

When i read the states.py, I discovered that in fact it is mostly repetitive processing a logical. So i use the `partial` to reconstruction this.