remove some duplication in PurchasesController