refactoring and javadocing