Fixed cleanTemplate function

cleanTemplate() function was targeting the wrong element