Update python, js implementation

Python and JS implementation are old.
The changes were re-converted.