Fixed mistake in for loop