use handler for loops

Change-Id: I371c86bcf935130cbdc1d88b98d23b7ae7023d2c