changed some malloc for new