refactor shipment state handling