added initial java implementation