Index issue solved, and recursion removed.