Archived code for performing the smart stack procedure