fix control logic so that it runs multiple iterations

Change-Id: I3bdb87a825e283042fb35a6a484cb4f66bbec155