Cleaning and implementing THD

cleaning up the code and one idea for implementing THD