Refactoring with custom elements