split out db creation function