setting up database functions