Fixed an infinite loop issue.