fix mismatched new delete... need to find a way to use unique_ptr for this