replace malloc with new