Your problems are on line 26. If you step through it with a debugger then the problem will become obvious.
Pay attention to the value that "get" has, while single-stepping through those loops.