fixed thread issues