second pull request

pull request to fix issue #3, issue #8 and issue #21