Refactoring code for better semantic HTML