Corrected wrong variable name

Corrected a wrong variable name.
 var to_name = new RegExp(name, 'i');
                                 ^
ReferenceError: name is not defined