new attempt at making set*id() safe and robust