fixed index race condition.