added stack code