simplified the circular queue logic