Unrelated, but is it an issue that this will loop forever if lookup returns NULL all the time?