queue logic