fixed threading issue