extract name function