Fixing bug in db selection script