perfoms safe thread