Code for all the trust algorithms