memory allocation error fixed