separated out the look up query code.