Refactored to operate as either a direct call or a generator