corrected memory allocation error; more testing