fix duplicate messages problem