moved ticket initialization to the end.