replaced malloc by xmalloc and NEW_ARR_A