database functions