fixed issue with threads