patching in tripsta's commit bb597b0