Generalize lookup

This generalizes the lookup command to make it easier to add other lookup functions