Fixed the endless loop problem (I overlooked this minor problem).