added javadocs and removed unnecessary code