Fixed cast to work with Java 1.6