made changes as suggested by Larsson for pull request #131