Little optimization with array working