Refactoring how comments are added to the DOM