make name search use subquery instead of join