replace while with for
changed to order to reverse