with unlimited number of samples..
modified unlimited numver of samples code