fixed bug in do_lookup