refactored out removeFromStack