simplify stack cache logic