patching in tripsta's commit 6fceed0