fix queue logic