Fixing new patch function