         }
         
         self.numberOfPalettes = palettes.count
-        widthPerTile = self.frame.size.width/CGFloat(numberOfColorsHorizontally)
+        widthPerBox = self.frame.size.width/CGFloat(numberOfColorsHorizontally)
         
         //TODO: Must round in case of odd number
         let numberOfPalettes = numberOfColorsHorizontally/numberOfColorsPerPalette

            for palette in palettes {
                startingPosition = draw(palette: palette,
                                        ctx: ctx,
                                        dimension: (widthPerTile, heightPerTile),
                                        startingPosition: startingPosition)
                counter = counter + 1
                

                    counter = 0
                    numberOfPalettesHorizontallyCounter = numberOfPalettesHorizontallyCounter + 1
                }
                startingPosition = (widthPerBox*CGFloat(counter*numberOfColorsPerPalette), heightPerBox*numberOfPalettesHorizontallyCounter)
            }
            
            drawCursor(ctx: ctx, position: boxSelected, dimension: boxSelectionSize, width: widthPerBox, height: heightPerBox)
        }
    }
    
    override func mouseDown(with event: NSEvent) {
        let p = event.locationInWindow
        let rawMouseCursor = convert(p, from: nil)
        let mouseCursor = CGPoint(x: rawMouseCursor.x, y: self.frame.size.height-rawMouseCursor.y)
        
        let boxCoordinatePosition = boxPosition(cursorPosition: mouseCursor,
                                                dimension: self.frame.size,
                                                numberOfHorizontalBoxes: numberOfColorsHorizontally,
                                                rows: numberOfRows)
        boxSelected = boxCoordinatePosition
        
        needsDisplay = true
    }
    
    func boxPosition(cursorPosition: CGPoint, dimension: CGSize, numberOfHorizontalBoxes: Int, rows: Int) -> (Int, Int) {
        func positionOnALine(position: CGFloat, width: CGFloat) -> Int {
            /**
             This is a three step process
             * Step 1 - Dividing the position/width this us what were the previous section that were past.
             * Step 2 - Get the remainder of diving position/width. If it is 0, then we are on the last section selected. If we are anything other than 0, then we have started moving toward a new section.
             * Step 3 - If the first section of the line is selected, then we will have started at 1 because the remainder will have been some value. Being that computer scientists start counting from 0 we then subtract one.
             */
            let previousSections = position/width
            let remainder = position.truncatingRemainder(dividingBy:width)
            return Int( previousSections + (remainder == 0 ? 0 : 1 )) - 1
        }
        
        // TODO: must find out a mathematical formula for finding the box position within a size given the number of boxes horizontally and vertically
        let widthPerBox = dimension.width/CGFloat(numberOfHorizontalBoxes)
        let heightPerBox = dimension.height/CGFloat(rows)
        
        let horizontalCounter = positionOnALine(position: cursorPosition.x, width: widthPerBox)
        let verticalCounter = positionOnALine(position: cursorPosition.y, width: heightPerBox)
        
        return (horizontalCounter, verticalCounter)
    }
    func drawCursor(ctx: CGContext, position: (x: Int, y: Int), dimension: Int, width: CGFloat, height: CGFloat) {
        ctx.setStrokeColor(NSColor.red.cgColor)
        ctx.setLineWidth(CGFloat(2.0))
        ctx.addRect(CGRect(x: width*CGFloat(position.x),
                           y: height*CGFloat(position.y),
                           width: width,
                           height: height))
        ctx.drawPath(using: .stroke)
    }
    // Once drawing the color boxes reaches the end of the view, then the cursor will wrap around back to position x = 0 and move down the height of the color box
    func draw(palette: Palette,
              ctx: CGContext,
              dimension: (width: CGFloat, height: CGFloat),
              startingPosition: (x: CGFloat, y: CGFloat)) -> (x: CGFloat, y: CGFloat) {
        ctx.setStrokeColor(NSColor.black.cgColor)
        ctx.setLineWidth(CGFloat(1))
        
        var startingXPosition = startingPosition.x
        var startingYPosition = startingPosition.y
        for color in palette.colors {
