minor performance improvement for ticket print

one should leave loops as early as possible.