more fix to issue #1 and added docstrings