Edited for Java 6 compatibility