added a few lines and some javadoc