Helper functions for mongodb