clone function and some litle changes