made get_consensus function cleaner