added functions to database.js