add stack in algorithm