fix array insert implementation