replacing java implementation