new version which log candidates to log file. And write result to file.