safe version - no threading