First 3 functions for db