Move clone logicinto library