updated with more flexibility, can query with a candidate ID