Parameter needed to be 'ref' to avoid null dereference error.