refactored ticket code