refactor to use model and to funnel everything through repository api