refactored ticket counting