made improvements to the layout page, reducing duplicate code