fixed stack overflow