fixing thread error