Improved the code for LTSV