Refactored factory into seperate class