fixes #1862

Fixed the issue and pushed code for review..