new leo script, python rewrite due to api change