Fixed a small infinite loop