Changed return type from queue to deque.
added a method for single goal.