bit of refactoring and renesting of html elements