added safeguards in tenant api