fixed the selection bug in state machines