fixes #1826

Fixed the issue, and committed the code for review, please check it.