finished consensus function