add checking whether allocated array size is exceeded