Refactoring to avoid race condition