preserve gallery ID order