change #id to #uid and set only when necessary