removed duplicate code, added docstrings
minor change in readme and comments