would it be possible to use the length of the Contents array - 1 instead of hard-coding 999?