migrating db stuff into separate class