fixes for accessing array as it is mutated