adding database functions from older project