replace the flush method