fixes #1788

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