added documentation + small refactoring