<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def modify_target(self, to_state, to_key):
 """Set both to_state and to_key at the same time to modify data flow target :param str to_state: State id of the target state :param int to_key: Data port id of the target port :raises exceptions.ValueError: If parameters have wrong types or the new data flow is not valid """

        if not isinstance(to_state, string_types):
            raise ValueError("Invalid data flow target port: from_state must be a string")
        if not isinstance(to_key, int):
            raise ValueError("Invalid data flow target port: from_outcome must be of type int")

        old_to_state = self.to_state
        old_to_key = self.to_key
        self._to_state = to_state
        self._to_key = to_key

        valid, message = self._check_validity()
        if not valid:
            self._to_state = old_to_state
            self._to_key = old_to_key
            raise ValueError("The data flow target could not be changed: {0}".format(message))