Implemented dequeue-function.