Corrected undefined identifier 'k'