rectified logging code & java version. added reduce class.