Building out variable links to query