Use functions and deal with the stack