adding my work of porting the code to java to this date