fixes #1961

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