fixing thread stop issue