vectorTH function updated so that it works in Clash