multitenant over more than 1 model

This modification makes multitenant work over more than 1 tenant model.