minor refactoring + docstrings