fix bug with stack limit