<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def _extract_residues(self):
 """ WHAT IF puts terminal atoms in new residues at the end for some reason.. """
        
        
        r_list = self.handle.getElementsByTagName("response")
        
        r_data = {}
        
        for r in r_list:
            data = self._parse_residue(r)
            res_id = (data['model'], data['chain'], data['number']) # (A, 1, 1), (A, 1, 2), ...
            if not r_data.has_key(res_id):
                r_data[res_id] = data
            else: # Some atoms get repeated at the end with TER Hydrogens/oxygens
                r_data[res_id]['atoms'] += data['atoms'] # Append Atoms
        
        for key in sorted(r_data.keys()):
            yield r_data[key]