Fix rewrite model script