Modified for JVM compatibility