fixed the array size and memery error