Refactoring: Extract function to create element