fix  controller state machine