factor out DAL (in progress)