Refactoring array checks