Fixed stack overflow exception