adding remaining state machine implementation