Changed Database functions to new database schema