rewrite native example for State Machine