using the stack for non-leaf procedure