updated from java6 to java 7 (plus formatting)