1st works version, not for the last k elements