use set instead of dict for candidates
use local variables