code optimization

Fixed: issue #8