Refactor output for cleaner HTML