function for Database