fix error in removing messages