move some queuestate code to queuestate file