I have also found out a new problem:
I have changed the switch function when the button is clicked to output msg.payload instead of payload array and the result is very strange. I am getting all kids of data ( even the data that I have not recently used as input) which implies that the DBdata is not cleared when i restart the flow. How to prevent this from happening?