changed db.on(close) event to db.on(end) in actions/random.js, also added error exception in index.js random function