Corrected Config db functions
Handled ensureIndex logic