added a create intervals method that takes a List<Integer>