wip
Improve states checking