updated to more closely match the Java version