`if not` should be `unless`, but if you don't want an `unless` with an `else`, then the two branches should be flipped so that this becomes `if new_pid` and lines 100 to 106 follow with line 98 after the else.