A better solution by radeinla for the pull request #223