Code for TS autmation