Fix type = 'both' issue of dvapply()