Refactor view configuration code