added js implementation