helper functions for db