added check for flush