replaced malloc with new in inclass 7