fixed a stack overflow