Update dynamic resizing function to help allocate memory more efficiently