changed check for table "res"