corrected stack code