reorder check for empty stack