fix array writing