applying patch from issue #134