assign by key in loop, remove need for array_unique, spacing