utils.wait in loops to avoid hogging CPU