Refactor name search functions