added 'weighted' option