Remove duplication in layout.js