if/else, fixing nested for