unnecessary loop in code