Replaced new with malloc