Add generic lookupvalue function