added flush statements