Protecting possible race condition