fixes #1735

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