Updated to be compatible with Java 6 :(