std::stack.top() returns by reference so how about we store it by reference to avoid an extra copy