change the vector w to be global