Solved the infinite looping bug.