modified random method