     func configureWithRoom(room: Room) {
         title = "\(room.title ?? "Room")"
         
+        guard let viewPurpose = viewPurpose else {
+            return
+        }
+        
         if let name = room.owner?.name, let surname = room.owner?.surname, let date = room.date, let limit = room.maxCount, let access = room.accessType {
 
             switch viewPurpose {

    
    let cloudKitHelper = CloudKitHelper()
    
    var viewPurpose: RoomDetailsPurpose {
        if room == nil {
            return RoomDetailsPurpose.Create
        } else if room?.owner?.recordID == userRecordID && room?.didEnd == false {
            return RoomDetailsPurpose.Edit
        } else {
            return RoomDetailsPurpose.View
        }
    }
    var userRecordID: CKRecordID?
    
    @IBAction func sliderValueChanged(sender: UISlider) {

            limitSlider.value = Float(limit)
            privateSwitch.on = access == AccessType.Private ? true : false
        }
    }
    
    func textFieldsAreFilled() -> Bool {
        guard let topText = topTextField.text, placeText = placeTextField.text, dateText = dateTextField.text, hourText = hourTextField.text else {
            return false
        }
        
        if !topText.isEmpty && !placeText.isEmpty && !dateText.isEmpty && !hourText.isEmpty {
            return true
        }
        
        return false
    }
    
    func createRoom() {
