Adding function previous_number to iterate to the last number. Still thinking of what kind of logic to use for this.