Made an ordinary for loop range-based

as suggested by [D.R.T]