change stack to deque and remove throws illegal throws