Refactor code of BillingThread