Array items not getting reassigned?