fix bug and add the clone function