Altered code to be Java 1.5 compatible