small loop optimizations