Fix color calculation and introduce new more performant array calculation