avoid race condition when switching object context