add java and js implementations