Fix checking duplicate messages