Refactor prime time solution