Refactor of validContentVariable and validContentVariableForReply function