Writing DB functions for CUPE (Incomplete)