threading now working correctly