fixing thread issues