changed java 7 specific code to java 6 compatible