Modified replace message condition