Fix broken logic when checking for valid message