Fix array and clean code