     return cell
   }
   
+  func textFieldDidBeginEditing(textField: UITextField) {
+    var cellIndex = textField.superview as UICollectionViewCell
+    let temp = collectionView.indexPathForCell(cellIndex)?.row
+    delegate.currentIndex = temp!
+  }
+  
   func textField(textField: UITextField, shouldChangeCharactersInRange range: NSRange, replacementString string: String) -> Bool {
     if countElements(string) > 0 {
       let lastCharacter = string.substringFromIndex(advance(string.endIndex, -1))
       
       if lastCharacter == " " {
-        delegate.tags.append("")
-        collectionView.insertItemsAtIndexPaths([NSIndexPath(forRow: delegate.getTags().count, inSection: 0)])
+        var idx = delegate.currentIndex+1
+        if delegate.currentIndex == delegate.tags.endIndex {
+          idx = delegate.tags.endIndex
+        }
+        delegate.tags.insert("", atIndex: idx)
+        let indexPath = NSIndexPath(forRow: idx, inSection: 0)
+        collectionView.insertItemsAtIndexPaths([indexPath])
+        let cell = collectionView.cellForItemAtIndexPath(indexPath) as tagCell
+        cell.textField.becomeFirstResponder()
         return false
       }
     }


class TagDelegate: TagProtocol {
  private var tags: [String] = [String]()
  
  convenience init(tags: [String]) {
    self.init()
    self.tags = tags
  }

  func setupDelegateAndDataSource(collectionView: UICollectionView) -> (delegate: TagCollectionViewDelegate, dataSource: TagDataSource) {
    let tagDelegate = TagCollectionViewDelegate()
    tagDelegate.delegate = self

  }
  
  func tagTextChanged(textField: UITextField) {
    if textField.text != "" && textField.text != " " {
      let pos : UITextPosition = textField.beginningOfDocument
      let pos2 : UITextPosition = textField.tokenizer.positionFromPosition(pos, toBoundary: .Word, inDirection: 0)!
      let range : UITextRange = textField.textRangeFromPosition(pos, toPosition: pos2)
