Fix for 1005

fixes #1005
Merge pull request #1120 from deiga/fix-1005

Fix for 1005