Fix ID lookup code