modify to use hierarchical model