Changed the loop to 0 to end instead of end to 0.