Beginning of queens function