remodelled db.js