Added logic for candidate creation