add 2 algorithm to do the same thing