fix bug to avoid recusrice invocation