update the code to collect messages