Updated changes suggested by @ashorin for pull request #6889