bugfix and review

review and bugfix of mergre pull request #13