update to David Holmes' patch