move db access to model lib