revised version of PR #154