modify flush logic