Merge pull request #21

with some slight changes