Refactored definition of lookup.