updated/fixed the flush callback