modified the way the lookup function works