rewrite check on python