len - 1 corrected