updated to new sample code from javacode.zip