fixed race condition-error