fixed issues #495, #500
Merge pull request #506 from safiyu/newissue

fixed issues #495, #500