docing and refactoring