updated stack implementation.