changed flushAll function