wait for flush