Fixed infinite loop

Still not quite right, though. :/