It works but does not pass the check for "there seems to be an infinite loop"