refactored factory initialization