updated for Java 6