let Flush() function waits for the finishing