fixes #1858

fixed the issue and committed the code for review please check it.