added invriant + function to twr