Changed code for stack operations