splitting out database functions