Refactor out addToStack