refactoring and javadocs