added javadoc, refactored