edited multiple TSD processing code