memory allocation fix