refactored factory a bit more