refactored to allow different number of consecutive numbers