small style fix
added a little error detection to make sure that everything is working well, and refactored mainDB.js a bit. Hope I'm not stepping on toes