Removed global variable k