refactor(server.go) refactor candidate loop