added java implementation