Queue building logic