started database functions; broken for now