Optimize how to set new element stack