Updated js implementation.