rewrited scan_name function