TRSHG code works!

it works, but some optimization is probably still necessary