refactoring and scaladoc