Fixed an infinite loop that would always occur. Shame on me for not testing.