modified to avoid reinit