Modifed pattern modification algo slightly