ex5 after refactoring and javadoc