Fixed logic errors in db_setup