Added code of pull request #52