improved forloop