pure java implementation