adding exception for empty stack