FSM implementation (WIP)