corrected memory allocation error