hopefully fixed the memory allocation error