changed order of inputs
added random genration of intervals and size