Initial implementation
Merge pull request #3 from adietish/master

corrected according to comments