fixes #1917

Fixed the issue and committed code for review