Implemenrs insert-right function