Extract reusable functions
handler: State change FSM