Fixed broken logic when waiting for data.