updated flush function - to be tested