fix bug--race condition