codes the while, but the testing throws stack too deep because loop detection is missing