add javadoc and clean code