added factory to assign a generator rather than if statements