replaced malloc with new