added the original java for comparison