Fix logic error in adding step IDs