                     allConstraints += "[leftSpacer][\(keyGapName)]"
                 }
                 else if isRightMarginGap {
-                    allConstraints += "[\(keyGapName)(\(canonicalMarginGap))][rightSpacer]"
+                    allConstraints += "[key\(j-1)x\(i)][\(keyGapName)(\(canonicalMarginGap))][rightSpacer]"
                 }
                 else {
-                    allConstraints += "[key\(0)x\(j-1)][\(keyGapName)(keyGap)]"
+                    allConstraints += "[key\(j-1)x\(i)][\(keyGapName)(keyGap)]"
                 }
                 
                 // each gap has the same height

        }
    }
    
    func createViews(keyboard: Array<Array<String>>) {
        for i in 0...keyboard.count {
            var rowGap = Spacer()
            let rowGapName = "rowGap\(i)"
            rowGap.layer.backgroundColor = UIColor.yellowColor().CGColor
            rowGap.setTranslatesAutoresizingMaskIntoConstraints(false)
            self.elements[rowGapName] = rowGap
            self.view.addSubview(rowGap)
            
            if (i < keyboard.count) {
                for j in 0...keyboard[i].count {
                    var keyGap = Spacer()
                    let keyGapName = "keyGap\(i)x\(j)"
                    keyGap.layer.backgroundColor = UIColor.blueColor().CGColor
                    keyGap.setTranslatesAutoresizingMaskIntoConstraints(false)
                    self.elements[keyGapName] = keyGap
                    self.view.addSubview(keyGap)

                allConstraints += "V:[topSpacer][\(rowGapName)(5)]" // TODO:
            }
            else if isBottomMarginGap {
                allConstraints += "V:[key\(0)x\(i-1)][\(rowGapName)(\(canonicalMarginGap))][bottomSpacer]"
            }
            else {
                if !canonicalRowGap {
