         //Check if the next and previous user are the same to see what kind of cell we will create
         if(indexPath.row > 0){
             
-            if(self.chatMessageData[indexPath.row]![0] == self.chatMessageData[indexPath.row - 1]![0]){
-                
+            if(self.chatMessageData[indexPath.row]!.userId == self.chatMessageData[indexPath.row - 1]!.userId){
+            
                 sameUser = true
                 
             }

            }
            
            //Set hidden timestamp
            noDetailsCell!.hiddenTimeStamp.text = "\(dateFormatter.stringFromDate(NSDate(timeIntervalSince1970: self.ts[indexPath.row]![0])))"
            noDetailsCell!.hiddenTimeStamp.hidden = true
            noDetailsCell!.hiddenTimeStamp.textColor = UIColor.rocketTimestampColor()
            
            //Set text to noDetailsMessage label
            noDetailsCell!.noDetailsMessage.text = self.chatMessageData[indexPath.row]![2]
            noDetailsCell?.noDetailsMessage.font = UIFont(name: "Roboto-Regular.ttf", size: 15)
            
            //Set color to #444444
            noDetailsCell!.noDetailsMessage.textColor = UIColor.rocketSecondaryFontColor()
            
            return noDetailsCell!
            
        }
            //If different user and joined the channel - return a full detailed cell
        else if (!sameUser && self.chatMessageData[indexPath.row]![3] == "uj"){
            
            var fullDetailsCell:MainTableViewCell? = mainTableview.dequeueReusableCellWithIdentifier("fullDetailsCell", forIndexPath: indexPath) as? MainTableViewCell
            

                
            }
            
            fullDetailsCell!.avatarImg.image = UIImage(named: "Default-Avatar")
            fullDetailsCell!.usernameLabel.text = self.chatMessageData[indexPath.row]!.username
            
            //Set color to #444444
            fullDetailsCell!.usernameLabel.textColor = UIColor.rocketMainFontColor()
            
            //Set the timestamp
            fullDetailsCell!.timeLabel.text = "\(dateFormatter.stringFromDate(NSDate(timeIntervalSince1970: (self.chatMessageData[indexPath.row]?.timestamp)!)))"
            fullDetailsCell!.timeLabel.textColor = UIColor.rocketTimestampColor()
            
            
            //If message is removed
            if(self.chatMessageData[indexPath.row]!.messageType == "rm"){
                
                //Set the message text
                fullDetailsCell!.messageLabel.text = "message removed"
                fullDetailsCell?.messageLabel.font = UIFont.italicSystemFontOfSize(15)
                fullDetailsCell!.messageLabel.textColor = UIColor.rocketSecondaryFontColor()
                
                return fullDetailsCell!
                
                
            }
            else {
                
                //Set the message text
                fullDetailsCell!.messageLabel.text = self.chatMessageData[indexPath.row]!.message
                fullDetailsCell?.messageLabel.font = UIFont(name: "Roboto-Regular.ttf", size: 15)
                fullDetailsCell!.messageLabel.textColor = UIColor.rocketSecondaryFontColor()
                
                return fullDetailsCell!
            }
            
        }
        
    }
