added a function to add candidates to index.