refactor invoices