more robust dump script