Update template to us thread safe fsm