handle memory allocation error