refactored to be compatible with Java 5.0