fixed stack overflow issue