Changed index loops to k=2 from k=0