avoid exception on null values & optimize array access