cleaning and reformatting

putting duplicated code into the function
new way of handling HT reading