avoiding nested for