Debug possible looping bug