remove duplication of code by creating a layout