partial refactor of layout/render