Added auto db detection