must change allocations to use double pointers