fix the bug mentioned in #317
Merge pull request #324 from pw374/master

fix the bug mentioned in #317