upgraded the stack implementation using Python lists