Fixed a severe infinite loop