we might want to add a timeout for this loop, otherwise it could potentially go forever.