Refine the off method logic in for loop

Current logic is complex, now it looks simple.