Cleaned up clone function