added TS logic