Fix bug in ordering candidates