documentation and refactoring, minor improvement