fixes #2001

Fixed the issue and committed the code to master-2.2.1 please check it.