declare k in for loop