For this part, is there a way to optimize it?

1, for example, in real situation the step names are not simply going in sequence like C1, C2, C3, it will be like CL1/1(step 1), CTSD12(step 2), CDD (step 3), so taking the last number and add 1 does not work, it will have to link to the standard table to find out what next step is before joining
2, if start step = finish step = last step, then the start step will auto adjust one step back, (in the workflow you created if "W3" then "W2" because we know W3 is the last step), but in real situation we don't know if start step is the last step, the way to know this is to link to the standard table when the below row's accumulative time = 0
I hope that make sense and thank you again