updating documentation and slight refactoring