rewrote patch script