Improve db detection