add latest code for tinst; messy