improve stack allocation