code for master/detail view.