I've changed the behaviour here to set a null at the end of the array if we're at the end, I think it makes thinks clearer.