revamp the lookup logic