Working in closures for dequeue function