fixed stack overflow problem