bug fix for issue 3470
Merge pull request #2264 from alalek:bug_fix_3470