trying to improve the threading issue