Fixed incorrect inputs now i -=1 so the loop doesnt exit. Also, fixed other loop bugs