updated code for k = 1
updated code for k = 1