js converted to py