ts port to HMscript