Fixed issue with threads