implemented new cloning algorithm

Signed-off-by: Daniel Fagnan <dnfagnan@gmail.com>