fixed async bug by using callback function in db.close