Added dequeue algorithm