refactor in TyCheck