prevent an infinity loop to happen
added some proper documentation