add layout and non-DRY code