implemented state machine class