Whole ticket logic refactoring