this might be better done with a more component model for the db