Updated clone function