implemented changes from comments on pull request 141