Updating middle layer code with restriction site cutting offset and pattern matching