added queue flush mechanism