fixes #1732

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