added javadoc and code refactoring