fixed insertr function