cleared up code; added javadoc