refactoring for a more complex layout