Fixed up the algorithm to add the ending numbers aswell