fixed stack overflow error