javascript implementation was out of sync with the python implementation