implementing stack pointer correctly