Add db function to controller