Fixed #789
Merge pull request #1002 from umpirsky/fix/issue-789-b

Fixed #789