patched from PR 169