fix for #1040
Merge pull request #1371 from drpy/master

fix for #1040