refactor - found a race condition