fixed clone function