- Added note in the code about the possibility of an endless loop. - Beautified the error message a bit.