made db detection better