rewrite to pass python code