this is a redo of pull request #1363

redo of pull request #1363