implementing fsm functions