Fixed crash when stack is empty