rewrite by flask