Refine the off method logic in for loop