write 3 db functions