move wildcard check BEFORE lookup