- fix issue #17, item 4
- optimize code