further working of database functions, needs testing