issue #888 fix (and more general cases)