internal stack optimization