duplicate algorithm