Refactor to use a single lookup function for every lookup type