fixed maximum stack space bug