added comments and javadoc